// pages/jobs/push/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jobTypeIcon: "cuIcon-unfold",
    jobLocationIcon: "cuIcon-unfold",
    educationIcon: "cuIcon-unfold",
    genderIcon: "cuIcon-unfold",
    workTypeIcon: "cuIcon-unfold",

    // Picker 数据
    pickerValue: 0,
    pickerRange: [],
    pickerType: "",

    // 底部弹出层数据
    isBottomSheetVisible: false,
    sheetType: "",
    job_type_list : ['全部','一口价','面议'],
    job_type      : '价格',
    area_cat      : ['威海市'],
    area_type_list : ["环翠区", "乳山市", "荣成市","文登区"],
    area_type      : '区域',
    educationList: ["不限", "中专", "大专", "本科", "硕士", "博士"],
    genderList: ["男", "女", "男女不限"],
    selectedEducation: "不限",
    selectedGender: "男女不限",
    work_type_list : [
      '物流配送','营销宣传','行政','服务业','市场营销','餐饮行业','影视传媒'
    ],
    work_list : [
      '分拣员','快递员','跑腿代办','送货司机','安保','建筑/房地产','驾驶员','装卸/搬运','驾驶员','操作工','物流','司机','交通/物流/仓储'
    ],
    isWorkSheetVisible:false,//工种弹窗
    selectedWorkType:"",
    selectedWork:"",
    cat_list:[
      {cat_id:1,cat_name:"未投递"},
      {cat_id:2,cat_name:"已投递"}
    ],
    TabCur : 0,
  },
    // 点击切换 tab
    tabSelect(e) {
      this.setData({
        TabCur: e.currentTarget.dataset.id // 更新当前选中的 tab
      });
    },
  //关闭弹窗
  closePopup() {
    this.setData({
      isBottomSheetVisible: false,
    });
  },
   //区域选择
   toggleAreaPicker(e){
        
    const index = e.detail.value
  
    this.setData({
      area_type : this.data.area_type_list[index]
    })
},
//切换岗位
  toggleJobPicker(e){
     
      const index = e.detail.value
    
      this.setData({
        job_type : this.data.job_type_list[index]
      })
  },


      // Picker 改变
  onPickerChange(e) {
    const selectedValue = this.data.pickerRange[e.detail.value];
    console.log(`选中的值为：${selectedValue}`);
  },


// 显示底部弹出层
showBottomSheet(e) {
  const type = e.currentTarget.dataset.type;
  const iconKey = `${type}Icon`;
  this.setData({
    sheetType: type,
    isBottomSheetVisible: true,
    [iconKey]: "cuIcon-fold",
  });
},

  // 选择弹出层选项
  selectSheetOption(e) {
    const value = e.currentTarget.dataset.value;
    if (this.data.sheetType === "education") {
      this.setData({ selectedEducation: value });
    } else if (this.data.sheetType === "gender") {
      this.setData({ selectedGender: value });
    }else if (this.data.sheetType === "jobType") {
      this.setData({ job_type: value });
    }else if (this.data.sheetType === "jobLocation") {
      this.setData({ area_type: value });
    }
  },

  //选择岗位类型
  select_work_type(e){
    const value = e.currentTarget.dataset.value;
    this.setData({ selectedWorkType: value });
  },

  //选择职位
  select_work(e){
    const value = e.currentTarget.dataset.value;
    this.setData({ selectedWork: value });
  },

    // 确认弹出层
confirmBottomSheet() {
  console.log(`确认选择：${this.data.selectedEducation || this.data.selectedGender}`);
  this.closeBottomSheet();
},

  // 关闭弹出层
  closeBottomSheet() {
    const iconKey = `${this.data.sheetType}Icon`;
    this.setData({
      isBottomSheetVisible: false,
      [iconKey]: "cuIcon-unfold",
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})